package com.jcompressor.entities;

import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.jcompressor.exceptions.JcompressorException;
import com.jcompressor.preferences.ConfigKeys;

public class Project implements Serializable {
	
	private static final long serialVersionUID = -4313271613782194886L;
	
	private String path;
	private String title;
	private String scriptOutput;
	private String styleOutput;
	private Map<String, String> properties;
	private LinkedList<String> options;
	private LinkedList<String> scripts;
	private LinkedList<String> styles;
	
	public Project() {
		this.properties = new HashMap<String, String>();
		this.options = new LinkedList<String>();
		this.scripts = new LinkedList<String>();
		this.styles = new LinkedList<String>();
	}
	
	public String getPath() {
		return this.path;
	}
	
	public String getTitle() {
		return this.title;
	}
	
	public String getScriptOutput() {
		return this.scriptOutput;
	}
	
	public String getStyleOutput() {
		return this.styleOutput;
	}
	
	public Map<String, String> getProperties() {
		return this.properties;
	}
	
	public LinkedList<String> getOptions() {
		return this.options;
	}
	
	public LinkedList<String> getScripts() {
		return this.scripts;
	}
	
	public LinkedList<String> getStyles() {
		return this.styles;
	}
	
	public String getOutput(final String type) {
		if (StringUtils.equals(type, ConfigKeys.JS)) {
			return this.scriptOutput;
		}
		else if (StringUtils.equals(type, ConfigKeys.CSS)) {
			return this.styleOutput;
		}
		
		throw new JcompressorException("Invalid output type (" + type + ")");
	}
	
	public LinkedList<String> getIncludes(final String type) {
		if (StringUtils.equals(type, ConfigKeys.JS)) {
			return this.getScripts();
		}
		else if (StringUtils.equals(type, ConfigKeys.CSS)) {
			return this.getStyles();
		}
		
		throw new JcompressorException("Invalid include type (" + type + ")");
	}
	
	public void setPath(final String path) {
		this.path = path;
	}
	
	public void setTitle(final String title) {
		this.title = title;
	}
	
	public void setScriptOutput(final String scriptOutput) {
		this.scriptOutput = scriptOutput;
	}
	
	public void setStyleOutput(final String styleOutput) {
		this.styleOutput = styleOutput;
	}
	
	public void setProperties(final Map<String, String> properties) {
		this.properties = properties;
	}
	
	public void setOptions(final LinkedList<String> options) {
		this.options = options;
	}
	
	public void addProperty(final String name, final String value) {
		this.properties.put(name, value);
	}
	
	public void addOption(final String option) {
		this.options.addLast(option);
	}
	
	public void addScript(final String script) {
		this.scripts.addLast(script);
	}
	
	public void addStyle(final String style) {
		this.styles.addLast(style);
	}
	
}